package BehaviorModel.mediatorModel;

public class RefrigeratorColleague extends Colleague{
    public RefrigeratorColleague(Mediator mediator,
                                 String name) {
        super(mediator,
              name);
        mediator.registerMediator(name,
                                 this);
    }

    /**
     * 功能描述: 打开冰箱
     */
    public void open(){
        System.out.println(" 打开电冰箱 ");
        sendMessage(1);
    }

    /**
     * 功能描述: 关闭冰箱
     */
    public void close(){
        System.out.println(" 关闭电冰箱 ");
        sendMessage(0);
    }

    /**
     * 功能描述: 回调到中介者
     *
     * @param stateChange
     */
    @Override
    public void sendMessage(int stateChange) {
        this.getMediator().getMessage(stateChange,this.name);
    }

}
